const path = require('path')
const htmlwebpackplugin = require('html-webpack-plugin')

module.exports = {
  mode:"development",
  devtool:"inline-source-map",
  entry:"./src/index.js",
  output:{
    path:path.resolve(__dirname,'./dist'),
    filename:'[name]-[hash].js'
  },
  devServer:{
    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 9000,
    open:true
  },
  module:{
    rules:[
      {
        test:/\.js$/,
        exclude:/node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            "plugins": [
              //支持装饰器
              ["@babel/plugin-proposal-decorators", { "legacy": true }],
              ["@babel/plugin-proposal-class-properties", { "loose" : true }],
              ["@babel/plugin-transform-runtime"]
            ]
          }
        }
      }
    ]
  },

  plugins:[new htmlwebpackplugin({
    filename:'index.html',
    template:'./index.html'
  })]

}